package com.itheima.web.request;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;

public class URLDemo {
    public static void main(String[] args) throws UnsupportedEncodingException {
        String username = "张三";
        System.out.println("转码前: " + username);
        //浏览器 utf8转码
        String encode1 = URLEncoder.encode(username,"UTF-8");
        System.out.println("浏览器转码: " + encode1);

        //tomcat ISO-8859-1解码
        String decode = URLDecoder.decode(encode1, "ISO-8859-1");
        System.out.println("tomcat 解码: " + decode);

        String encode = URLEncoder.encode(decode, "ISO-8859-1");
        System.out.println("tomcat url解码: " + encode);
        System.out.println(URLDecoder.decode(encode, "UTF-8"));

    }
}
